﻿package com.neriksworkshop.colourLoversDemos.wordPatches.view 
{
	import com.neriksworkshop.lib.colourLovers.items.IGraphicItem;
	import com.neriksworkshop.lib.colourLovers.items.Palette;
	import flash.display.Sprite;
	import flash.geom.Rectangle;
	import gs.TweenLite;
	
	/**
	 * ...
	 * @author Erik
	 */
	public class Blurb extends Sprite
	{
		protected var _baseSprite:Sprite;
		protected var _mask:Sprite;
		
		protected var _radius:Number;
		
		protected var _title:String;
		
		public function Blurb(_base:IGraphicItem) 
		{
			this._baseSprite = _base.sprite;
			this._title = _base.title;
			
			//FIXME see why baseSprite can be null
			if (!_baseSprite) return;
	
			_radius = _baseSprite.width / 2;

			_mask = new Sprite();
			_mask.graphics.beginFill(0xFF00FF);
			_mask.graphics.drawCircle(0, 0, _radius);

			_baseSprite.x = _baseSprite.y = - _radius;
			rotation = (Math.random() * 360) - 180;
			_baseSprite.mask = _mask;
			
			
			addChild(_baseSprite);
			addChild(_mask);
			
			start();
		}
		
		private function start():void
		{
			TweenLite.from(_mask, .15 + .5*Math.random(), { scaleX: 0, scaleY: 0 } ); 
			
		}
		
		public function get title():String { return _title; }
		
	}
	
}